package com.luckku.boot.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.luckku.boot.common.api.ApiResult;
import com.luckku.boot.model.entity.Seckill;
import com.luckku.boot.service.ISeckillService;
import com.luckku.boot.utils.SnowFlakeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @author luckku
 * @date 2021/12/13
 */

@Controller
@RequestMapping("/seckill")
public class SeckillController {

    @Autowired
    ISeckillService seckillService;

    @Autowired
    SnowFlakeUtil snowFlakeUtil;

    /**
     * /seckill/info
     * 获取秒杀商品（4个）
     */
    @ResponseBody
    @GetMapping("/info")
    public ApiResult<List<Seckill>> getSeckillInfo(@RequestParam("storeId") String storeId) {
        List<Seckill> list = seckillService.list(
                new QueryWrapper<Seckill>()
                        .eq("store_id",storeId)
                        .last("limit 0,4")
        );
        return ApiResult.success(list);
    }

}
